import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

import path from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import eslintPlugin from 'vite-plugin-eslint';

// https://vitejs.dev/config/
export default defineConfig({
	server: {
		hmr: true
	},
	plugins: [
		vue(),

		AutoImport({
			resolvers: [ElementPlusResolver()],
		}),
		Components({
			resolvers: [ElementPlusResolver()],
		}),

		createSvgIconsPlugin({
			// 指定需要缓存的图标文件夹(路径为存放所有svg图标的文件夹不单个svg图标)
			iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')],
			// 指定symbolId格式
			symbolId: 'icon-[name]'
		}),

		eslintPlugin({
			include: ['src/**/*.ts', 'src/**/*.vue', 'src/*.ts', 'src/*.vue'],
		})
	],
	resolve: {
		alias: {
			'@': path.resolve(__dirname, './src'),
		}
	},
});
